<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\InCode
 *
 * @property int $id
 * @property string $code 邀请码
 * @property int $user_id 创建人
 * @property int $status 使用状态
 * @property int|null $used_user 使用者
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @property-read \App\Models\User $used
 * @property-read \App\Models\User $user
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\InCode whereCode($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\InCode whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\InCode whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\InCode whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\InCode whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\InCode whereUsedUser($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\InCode whereUserId($value)
 * @mixin \Eloquent
 */
class InCode extends Model
{
    protected $table = 'in_codes';

    protected $guarded = [];
    //

    /**拥有此邀请码的用户
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user(){
        return $this->belongsTo('App\Models\User');
    }

    /**
     * 使用者的user_id
     */
    public function used(){
        return $this->hasOne('App\Models\User','id','used_user');
    }
}
